<template>
	<view>

		<checkbox-group @change="handleChangeChkBox">
		<view class="list-item" v-for="item ,index in dataSource" :key="item.DATAKEY">
			<view @tap="onClick(index)" class="list-click-area">
				<view class="item-top">
					<view class="setion-left">
						<text class="left-text-top">{{item[fields.name]}}</text>
					</view>
					<view class="setion-right">
						<view class="right-text-top">{{item[fields.date]}}</view>
					</view>
				</view>
				<view class="item-bot">
					<view class="item-main" v-for="items,i in fields.columns" :key="i">
						<text class="tip">{{items.title}}:</text>
						<text class="content">{{item[items.dataKey] || ''}}</text>
					</view>

				</view>
			</view>
			<view class="tag-box">
				<text class="tag-sty" v-for=" items,j in item[fields.person]" :key="j">{{items}}</text>

			</view>
			<view class="chkbox" v-if="showCheckBox">
				<checkbox :value="index"/>
				<!-- <view class="inner" v-if=" selectedChks[index] === index">
					
				</view> -->
			</view>
		</view>
		</checkbox-group>
	</view>
</template>

<script>
	/**
	 *  简单封装了下， 应用范围比较狭窄，可以在此基础上进行扩展使用
	 *  比如加入image， iconSize可控等
	 */
	export default {
		data() {
			return {
				typeList: {
					left: 'icon-zuo',
					right: 'icon-you',
					up: 'icon-shang',
					down: 'icon-xia'
				},
				isChecked: false,
				actIndex:null,
				selectedChks:[0,1,2,3,4,5,6,7,8,9]
			}
		},
		props: {
			fields: {
				type: Object,
				default: {},
			},
			dataSource: {
				type: Array,
				default: []
			},
			bindclick: {
				type: Function,
				default: null
			},
			showCheckBox: {
				type: Boolean,
				default: false
			}
		},
		methods: {
			onClick(index) {
				this.$emit('onClick',index);
			},
			handleChangeChkBox(e) {
				const index = e.detail.value
				this.$emit('onSelect',index)
			},
			reset(){
				this.actIndex = null;
			}
		},
	}
</script>

<style scoped lang='scss'>
	.list-item {
		background-color: #FFFFFF;
		margin: 20rpx 30rpx 0 30rpx;
		padding: 32rpx;
		border-radius: 20rpx;
		position: relative;

		.chkbox {
			width: 40rpx;
			height: 40rpx;
			position: absolute;
			left: 0;
			bottom: 0;
			border-radius: 6px;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		.item-main {
			display: flex;

			.tip {
				color: #333;
				flex-shrink: 0;
				margin-right: 5px;
			}

			.content {
				flex: 1;
				overflow: hidden;
				display: -webkit-box;
				-webkit-line-clamp: 2;
				overflow: hidden;
				text-overflow: ellipsis;
				-webkit-box-orient: vertical;
			}
		}


		.item-top {
			display: flex;
			justify-content: space-between;

			.setion-left {
				display: flex;
				flex-direction: column;
				margin-bottom: 30rpx;

				.left-text-top {
					font-size: 30rpx;
				}

				.left-text-bot {
					font-size: 24rpx;
					margin: 14rpx 0;
					color: #999;
				}
			}

			.setion-right {
				display: flex;
				flex-direction: column;
				align-items: flex-end;

				.right-text-top {
					height: 30rpx;
					line-height: 30rpx;
					text-align: center;
					border-radius: 4rpx;
					font-size: 24rpx;
					font-weight: normal;
					color: #999999;
				}

				.right-text-bot {
					margin-top: 22rpx;
					font-size: 28rpx;
					font-weight: normal;
					color: #999999;
				}
			}
		}

		.item-bot {
			.item-main {
				font-family: AlibabaPuHuiTi-Regular;
				font-size: 28rpx;
				font-weight: normal;
				line-height: 34rpx;
				letter-spacing: 0px;
				color: #999999;
				margin-bottom: 10rpx;
			}

		}

		.tag-box {
			margin-top: 22rpx;

			.tag-sty {
				margin-right: 10rpx;
				padding: 6rpx 8rpx;
				font-size: 24rpx;
				border-radius: 4rpx;
				color: #999999;
				background-color: #e6e6e6;
			}
		}
	}
</style>
